from django.db import models


# Create your models here.


# 标题、内容、首图、标记、浏览次数、赞赏开启、版权开启、评论开启、是否发布、创建时间、更新时间、描述
class Blog(models.Model):
    YES_OR_NO_CHOICES = [
        ('Y', '开启'),
        ('N', '关闭')
    ]

    title = models.CharField(max_length=255, blank=True, null=True, verbose_name='标题')
    content = models.TextField(verbose_name='内容')
    first_img = models.ImageField(upload_to='photo', verbose_name='首图')
    flag = models.CharField(max_length=255, blank=True, null=True, verbose_name='标记/原创/转载...')
    views = models.PositiveIntegerField(blank=True, null=True, verbose_name='浏览次数')
    appreciation = models.CharField(choices=YES_OR_NO_CHOICES, blank=True, null=True, verbose_name='赞赏是否开启')
    comment_enable = models.CharField(choices=YES_OR_NO_CHOICES, blank=True, null=True, verbose_name='评论是否开启')
    comment_count = models.IntegerField(blank=True, null=True, verbose_name='评论次数')
    share_statement = models.CharField(choices=YES_OR_NO_CHOICES, blank=True, null=True, verbose_name='版权是否开启')
    recommend = models.CharField(choices=YES_OR_NO_CHOICES, blank=True, null=True, verbose_name='是否推荐')
    published = models.CharField(choices=YES_OR_NO_CHOICES, blank=True, null=True, verbose_name='是否发布')
    description = models.CharField(max_length=255, blank=True, null=True, verbose_name='描述')
    create_time = models.DateTimeField(auto_now=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now_add=True, verbose_name='更新时间')

    class Meta:
        db_table = 't_blog'
        verbose_name = '博客内容'
        verbose_name_plural = '博客内容'

